import { PrimeVueResolver } from '@primevue/auto-import-resolver';
import vue from '@vitejs/plugin-vue';
import { fileURLToPath, URL } from 'node:url';
import { visualizer } from 'rollup-plugin-visualizer';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
    base: '/',
    optimizeDeps: {
        noDiscovery: true,
        include: ['quill', 'quill-delta']
    },
    plugins: [
        vue(),
        Components({
            resolvers: [
                PrimeVueResolver({
                    // 关键配置项
                    importStyle: true, // 自动导入组件CSS样式
                    importTheme: 'md', // 可选主题配置 (如'md'表示Material Design风格)
                    cssLayer: 'primevue' // 将样式注入指定CSS层
                })
            ]
        }),
        visualizer({
            open: true,
            gzipSize: true
        })
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    server: {
        proxy: {
            '/api': {
                target: 'http://82.157.114.53:8002',
                changeOrigin: true
            }
        }
    },
    build: {
        rollupOptions: {
            output: {
                manualChunks: {
                    // 将大依赖包单独分块
                    primevue: ['primevue'],
                    'vue-vendor': ['vue', 'vue-router', 'pinia'],
                    lodash: ['lodash-es']
                }
            }
        },
        // 调整警告阈值（可选）
        chunkSizeWarningLimit: 1000
    }
});
